package com.yhf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(
                        new ApiInfo(
                                //标题
                                "标题测试swagger",
                                //描述
                                "描述信息",
                                //版本
                                "版本",
                                //服务地址
                                "地址访问",
                                //作者信息
                                new Contact("作者姓名", "地址", "邮箱"),
                                //许可证
                                "许可证",
                                //许可证URL
                                "许可证URL",
                                //扩展信息
                                new ArrayList<>()
                        )
                )
                //组织名
                .groupName("com.yhf")
                //接口规则
                .select()
                //限定接口包
                .apis(RequestHandlerSelectors.basePackage("com.yhf.controller"))
                //限定接口url
                .paths(PathSelectors.ant("/**"))
                .build();
    }

}
